<link rel="stylesheet" href="<{$res_url}>/css/common.css"/>
<link rel="stylesheet" href="<{$res_url}>/css/index.css"/>
<div class="outbox" id="ms_list">
  <div id="J_body">
	<!--商品列表-->
	<div class="fixed_box">
	 <div class="top_box">
	 <a href="javascript:history.back()"><span class="top_back J_topback"></span></a>
	 <h1>秒杀</h1>
	  <a href="http://www.jl86.cn/index.php/wap/special-index-(6).html" class="miji J_seckillMiji"></a>
  </div> <div class="swiper-container ban_box swiper-container-horizontal">

	<ul class="swiper-wrapper banner_list J_menu" id="menu">


	  <{foreach from=$whyshopseckill_time item=item key=key}>

	  <li  class="swiper-slide <{$item.isactive}>" id="actno_<{$item.whyshopseckill_id}>"   start_time="<{$item.seckill_starttime*1000}>"  end_time="<{$item.seckill_endtime*1000}>" seckill_id="<{$item.whyshopseckill_id}>"  data-actno="<{$item.whyshopseckill_time}>" static_org="<{$item.static_org}>" static="<{$item.seckill_static}>" title="<{if $item.isactive}>限时限量疯狂抢购<{elseif $item.static_org==0}>本场次还有宝贝可以继续抢购哦<{elseif $item.static_org==1}>提前设置提醒不错过<{/if}>" style=""><p><{$item.short_time}></p><p><{$item.seckill_static}></p>
		<div class="sanjiao" <{if $item.isactive}>style="display:block"<{/if}>></div>
	  </li>



	  <{/foreach}>


	</ul>

  </div></div><div class="banner_box J_remove"> <div class="swiper-container swiper-container2 swiper-container-horizontal">     <div class="swiper-wrapper">              </div>     <div class="swiper-pagination swiper-pagination-clickable swiper-pagination-bullets"></div> </div></div>


  <div class="ms_time J_remove" id="J_ms_time">
	<h3 class="h3"><{$item.seckill_title}>  </h3>
	<b></b>
	<div class="timer-simple-seconds" timer="" timestamp="" datetime="">
<!--       <span class="day">0</span>天 -->
	  <span class="hour">00</span>:
	  <span class="minute">00</span>:
	  <span class="second">00</span>
	</div>
  </div>


  <div id="J_list" class="qing888">

  </div>


</div>
</div>
<a class="back_top" href="#" id="botto" style="display:none;"></a>
<script type="text/javascript">
  $(window).scroll(function(){
  $(this).scrollTop()>400?
  $(".back_top").css("display","block"):
  $(".back_top").hide()})
</script>
<script type="text/javascript" src="<{$res_url}>/js/jquery.min.js"></script>
<script>jQuery.noConflict();</script>
<script type="text/javascript" src="<{$res_url}>/js/time.js"></script>
<script type="text/javascript">
  (function($){
	  var intval = null;
	  var toNotify=function(){

		  $('.seckill_notify').on('click',function(){
			  var _this=$(this);
			  $.ajax({
				  type: "post",
				  url: '<{link app=whyshopseckill ctl=wap_whyshopseckill act=addyuyue}>',
				  dataType:'json',
				  data: {'seckill_goods_id':_this.attr('data-seckill_goods_id'),'whyshopseckill_id':_this.attr('data-whyshopseckill_id'),'seckill_product_id':_this.attr('data-whyshopseckill_product_id')},
				  success: function (msg) {
					if(msg.error){
						if(msg.error!='请先登录') {
							alert(msg.error);
						}
						if(msg.redirect){
							window.location.href=msg.redirect;
						}
						return false;
					}
					  else{
						alert(msg.success);

					}

				  }
			  })
		  });

		 //  $('.price_t').on('click',function(){
			// var _this=$(this);
			// window.location.href=_this.attr('url');
		 //  })
	  };

	  function getseckill(nowsel) {
		  var id = nowsel.attr('seckill_id');
		  var start_time = nowsel.attr('start_time');
		  var next_begin_time=nowsel.next('li').attr('start_time');
		  var end_time =next_begin_time?next_begin_time:nowsel.attr('end_time');//是显示离下一场开始的时间2017-03-23 10:19:06
		  var title = nowsel.attr('title');
		  var static = nowsel.attr('static_org');

		  var params = {"id": id};
		  var url = "<{link app=whyshopseckill ctl=wap_whyshopseckill act=getgoods}>";
		  $('#J_list').css('display', 'none');

		  $.ajax({
			  type: "post",
			  url: url,
			  data: params,
			  success: function (msg) {


				  $('#J_list').html(msg).fadeIn('100');
				  // alert(111);
				  toNotify();

			  }
		  });


		  //算倒计时

		  // $('.timer-simple-seconds').attr('timer',1000);

		  $('#J_ms_time b').show();

		  //秒杀标题替换
		  $('#J_ms_time h3').html(title);

		  //背景变化
		  $('.swiper-slide').removeClass('skactive');
		  nowsel.addClass('skactive');

		  //是 结束 还是 离开始
		  if (static == '0') {
			  $('#J_ms_time b').html('离本场结束');
			  $('.timer-simple-seconds').attr('timestamp', end_time);

			  $('.timer-simple-seconds').show();
			  $('#J_ms_time h3').removeClass('notbegin');

			 // $('#J_ms_time h3').html("限时限量疯狂抢购");


		  }
		  else if (static == '1') {
			  $('#J_ms_time b').html('离本场开始');
			  $('.timer-simple-seconds').attr('timestamp', start_time);
			  $('.timer-simple-seconds').show();

			  $('#J_ms_time h3').addClass('notbegin');
			//  $('#J_ms_time h3').html("提前设置提醒不错过");


		  } else if (static == '2') {
			  $('#J_ms_time b').html('');
			  $('.timer-simple-seconds').hide();
			  //$('.timer-simple-seconds').attr('timestamp',end_time);


		  }
		  if(nowsel.attr('static')=='已开抢'){
			  $('#J_ms_time b').hide();
			  $('.timer-simple-seconds').hide();
		  }

		  //对所有的计时器进行处理
		  var timers = $(".timer-simple-seconds");


		  for (var i = 0; i < timers.length; i++) {
			  var timer = $(timers[i]);


			  clearInterval(intval);//先去掉

			  if (timer.attr("timestamp")) {
				  //如果是时间戳，则预处理一下时间为倒计时秒数
				  prepareProcessTimestamp2Timer(timer);
			  } else if (timer.attr("datetime")) {
				  //处理时间格式为倒计时秒数
				  prepareProcessDatetime2Timer(timer);
			  }
			  //先调用一次，避免误差
			  processTimer(timer);

			  intval = setInterval(processTimer, 1000, timer);

		  }


	  }
	  $('.swiper-slide').on('click', function () {
		  var _this = $(this);
		  getseckill(_this);
		  $(this).children(".sanjiao").show();
		  $(this).siblings().children('.sanjiao').hide();
		  //倒计时
	  });
	  $(document).ready(function () {
		  var nowsel = $('.skactive');
		  getseckill(nowsel);
	  });
  })(jQuery);
</script>